import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'



//这一块的路径不能进行权限划分 也就是需要所有用户看到的放在这个数组下面 有对象
export const constantRoutes = [

  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },


]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  /** when your routing map is too long, you can split it into small modules **/

  // {
  //   path: '/',
  //   component: Layout,
  //   children: [{
  //     path: 'home',
  //     name: 'Home',
  //     component: () => import('@/views/home/index'),
  //     meta: {title: '首页', icon: 'shouye1'}
  //   }]
  // },

  {
    path: '/',
    component: Layout,
    children: [{
      path: 'newIndex',
      name: 'newIndex',
      component: () => import('@/views/home/newIndex'),
      meta: {title: '首页', icon: 'shouye1'}
    }]
  },






  //订单信息
  {
    path: '/orderManagerInfo',
    component: Layout,
    name: 'OrderManagerInfo',
    meta: {
      title: '订单信息',
      icon: 'order'
      , roles: ['oa管理员']
    },
    children: [
      {
        path: 'orderInfo',
        name: '',
        component: () => import('@/views/orderInfo/orderList'),
        meta: {
          title: '订单管理',
          icon: 'orderlyl'
        }
      },
      {
        path: 'shoppingCarInfo',
        name: '',
        component: () => import('@/views/orderInfo/shoppingCar'),
        meta: {
          title: '购物车信息',
          icon: 'shoppingCar'
        }
      },





    ]
  },


  //工作管理
  {
    path: '/workInfo',
    component: Layout,
    name: 'WorkInfo',
    meta: {
      title: '工作管理',
      icon: 'work'
      , roles: ['oa管理员']
    },
    children: [
      {
        path: 'WorkInfoDay',
        name: '',
        component: () => import('@/views/workInfo/workDay'),
        meta: {
          title: '今日工作',
          icon: 'receptionDay'
        }
      },
      {
        path: 'WorkInfo',
        name: '',
        component: () => import('@/views/workInfo/workInfo'),
        meta: {
          title: '历史工作',
          icon: 'reception'
        }
      },





    ]
  },

  //预约管理
  {
    path: '/subscribeInfo',
    component: Layout,
    name: 'SubscribeInfo',
    meta: {
      title: '预约管理',
      icon: 'subscribeInfo'
      , roles: ['oa管理员']
    },
    children: [
      {
        path: 'receptionDay',
        name: '',
        component: () => import('@/views/subscribe/receptionDay'),
        meta: {
          title: '今日预约',
          icon: 'receptionDay'
        }
      },
      {
        path: 'reception',
        name: '',
        component: () => import('@/views/subscribe/reception'),
        meta: {
          title: '历史预约',
          icon: 'reception'
        }
      },





    ]
  },

  // 人员管理
  {
    path: '/personalInfo',
    component: Layout,
    name: 'PersonalInfo',
    meta: {
      title: '人员管理',
      icon: 'personalInfo'
      , roles: ['oa管理员']
    },
    children: [
      {
        path: 'users',
        name: '',
        component: () => import('@/views/personal/users'),
        meta: {
          title: '账户管理',
          icon: 'account'
        }
      },

      {
        path: 'physician',
        name: '',
        component: () => import('@/views/personal/physician'),
        meta: {
          title: '医师管理',
          icon: 'physician'
        }
      },

      {
        path: 'userInfo',
        name: '',
        component: () => import('@/views/personal/client'),
        meta: {
          title: '顾客管理',
          icon: 'userInfo'
        }
      },

      {
        path: 'userAddressInfo',
        name: '',
        component: () => import('@/views/personal/userAddress'),
        meta: {
          title: '顾客地址',
          icon: 'userAddress'
        }
      },


    ]
  },

  // 基础信息
  {
    path: '/baseInfo',
    component: Layout,
    name: 'BaseInfo',
    meta: {
      title: '基础信息',
      icon: 'baseInfo'
      , roles: ['oa管理员']
    },
    children: [
      {
        path: 'product',
        name: '',
        component: () => import('@/views/product/product'),
        meta: {
          title: '产品信息',
          icon: 'product'
        }
      },

      {
        path: 'set_meal',
        name: '',
        component: () => import('@/views/subscribe/setMeal'),
        meta: {
          title: '套餐管理',
          icon: 'set_meal'
        }
      },

      {
        path: 'store',
        name: '',
        component: () => import('@/views/store/store'),
        meta: {
          title: '门店信息',
          icon: 'store'
        }
      },
      {
        path: 'map',
        name: '',
        component: () => import('@/views/map/map'),
        meta: {
          title: '地图设置',
          icon: 'map'
        }
      },


    ]
  },

// 类型管理
  {
    path: '/typeManage',
    component: Layout,
    name: 'typeManage',
    meta: {
      title: '类型管理',
      icon: 'typeManage'
      , roles: ['oa管理员']
    },
    children: [


      {
        path: 'productType',
        name: '',
        component: () => import('@/views/type/productType'),
        meta: {
          title: '产品类型',
          icon: 'productType'
        }
      },

      {
        path: 'memberType',
        name: '',
        component: () => import('@/views/type/memberType'),
        meta: {
          title: '会员类型',
          icon: 'memberType'
        }
      },


      {
        path: 'physicianGrade',
        name: '',
        component: () => import('@/views/type/physicianGrade'),
        meta: {
          title: '医师等级',
          icon: 'physicianGrade'
        }
      },

      {
        path: 'physicianType',
        name: '',
        component: () => import('@/views/type/physicianType'),
        meta: {
          title: '医师类型',
          icon: 'physicianType'
        }
      },
      {
        path: 'utilInfo',
        name: '',
        component: () => import('@/views/type/utilInfo'),
        meta: {
          title: '规格类型',
          icon: 'setMealDetail'
        }
      },
      {
        path: 'area',
        name: '',
        component: () => import('@/views/area/areaInfo'),
        meta: {
          title: '地区信息',
          icon: 'area'
        }
      },
    ]
  },

  // 系统设置
  {
    path: '/baseConfig',
    component: Layout,
    name: 'BaseConfig',
    meta: {
      title: '系统设置',
      icon: 'system'
      , roles: ['oa管理员']
    },
    children: [

      {
        path: 'dates',
        name: '',
        component: () => import('@/views/dates/dates'),
        meta: {
          title: '日期管理',
          icon: 'dates'
        }
      },
      {
        path: 'period4',
        name: '',
        component: () => import('@/views/logs/index'),
        meta: {
          title: '日志管理',
          icon: 'logs'
        }
      },


      {
        path: 'loginmanager',
        name: '',
        component: () => import('@/views/loginmanager/index'),
        meta: {
          title: '登录统计',
          icon: 'statistics'
        }
      }

    ]
  },




]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
